package edu.ccut.saturn.studio.logic.model.saturn;

import org.w3c.dom.Node;

import edu.ccut.saturn.studio.core.util.xml.SaturnW3CUtil;

public class SaturnSwichVO {
	private String isDefault = "false";
	private String connection = "";
	private String key = "";

	public String getIsDefault() {
		return isDefault;
	}

	public void setIsDefault(String isDefault) {
		this.isDefault = isDefault;
	}

	public String getConnection() {
		return connection;
	}

	public void setConnection(String connection) {
		this.connection = connection;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public Node creatNode(Node node) {
		Node ifNode = SaturnW3CUtil.createChildNode(node, "if", null);
		
		SaturnW3CUtil.createChildNode(ifNode, "expr", this.getKey());
		SaturnW3CUtil.createAttribute(ifNode, "isDefault", this.getIsDefault());
		SaturnW3CUtil.createAttribute(ifNode, "then", this.getConnection());

		return ifNode;
	}

	public boolean equals(SaturnSwichVO saturn) {
		if (this.connection.equals(saturn.getConnection())
				&& this.isDefault.equals(this.getIsDefault())
				&& this.key.equals(this.getKey())) {
			return true;
		} else {
			return false;
		}
	}
}
